package com.tarena.lbs.basic.web.repository.impl;

import com.tarena.lbs.basic.web.mapper.DictItemMapper;
import com.tarena.lbs.basic.web.repository.DictItemRepository;
import com.tarena.lbs.common.basic.converter.DictItemConverter;
import com.tarena.lbs.pojo.basic.bo.DictItemBO;
import com.tarena.lbs.pojo.basic.dos.DictItemDO;
import com.tarena.lbs.pojo.basic.query.DictItemQuery;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class DictItemRepositoryImpl implements DictItemRepository {

    @Autowired
    private DictItemMapper dictItemMapper;

    @Autowired
    private DictItemConverter dictItemConverter;

    @Override
    public void insert(DictItemDO dictItemDO) {
        dictItemMapper.insert(dictItemDO);
    }

    @Override
    public DictItemBO detail(Integer id) {
        DictItemDO dictItemDO = dictItemMapper.selectByPrimaryKey(id);
        return dictItemConverter.do2bo(dictItemDO);
    }

    @Override
    public void update(DictItemDO record) {
        dictItemMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public void delete(Integer id) {
        dictItemMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<DictItemDO> selectByCondition(DictItemQuery dictItemQuery) {
        List<DictItemDO> dictItemDOS = dictItemMapper.selectByCondition(dictItemQuery);
        return  dictItemDOS;
    }
}
